package com.zhuang.designpattern.singleton;

/**
 * description: 饿汉模式(线程安全)
 * date: 2022/9/14 18:25
 * author: Zhuang
 * version: 1.0
 */
public class Singleton_03 {
    public static void main(String[] args) {
        Singleton03 instance1 = Singleton03.getInstance();
        Singleton03 instance2 = Singleton03.getInstance();

        System.out.println("instance1 = " + instance1);
        System.out.println("instance2 = " + instance2);
    }
}

class Singleton03 {
    private static final Singleton03 instance = new Singleton03();

    private Singleton03() {

    }

    public static Singleton03 getInstance() {
        return instance;
    }
}
